package com.louis;

import com.louis.asynctask.AsyncTaskActivity;
import com.louis.contact.ContactListActivity;
import com.louis.handler.AndroidHandlerActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Android_learningActivity extends Activity {
	public final String TAG = "Main";
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	this.setContentView(R.layout.main);
        ArrayAdapter<CharSequence> adapter= ArrayAdapter.createFromResource(this, R.array.array1, android.R.layout.simple_list_item_1);
        ListView lv = (ListView)findViewById(R.id.view1);
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(new OnItemClickListener(){
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				Log.i(TAG,arg0.getAdapter().getItem(arg2).toString());
				switch(arg2){
				case 0:
					break;
				case 1:
					break;
				case 2:
					Intent intent = new Intent(Android_learningActivity.this, AndroidHandlerActivity.class);
					Android_learningActivity.this.startActivity(intent);
					break;
				case 3:
					Intent asyncIntent = new Intent(Android_learningActivity.this,AsyncTaskActivity.class);
					Android_learningActivity.this.startActivity(asyncIntent);
				default:
				case 4:
					Intent contentProvider = new Intent(Android_learningActivity.this,ContactListActivity.class);
					Android_learningActivity.this.startActivity(contentProvider);
					break; 
				}
			}
        	
        });
    }
}